﻿using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using SelfService.HaiTai;
using SelfService.Model.Models.Auto;
using SelfService.Services;
using SelfService.Tasks;
using SelfService.XiaoEn;
using TT;

namespace SelfService
{
    public static class ServiceExtension
    {
        public static void CustomService(this IServiceCollection services, IConfiguration configRoot)
        {
            services.AddScoped<Logger>();
            //注入聚合支付
            services.AddXiaoEnPayService(configRoot);
            //医保结算自动退款
            services.AddScoped<AutoRefundTask>();
            //海泰接口
            services.AddHaiTaiService(configRoot);
#if !DEBUG
            //定时任务
            services.AddHostedService<TaskService>();
#endif
            services.AddScoped<UpdateMedicalProjectsTask>();
            services.AddScoped<PayTask>();
            services.AddScoped<RefundTask>();
            //注入自动冲正服务
            services.AddScoped<AddCreditTask>();
            //清理日志服务
            services.AddScoped<ClearLogTask>();
            //注入旧自助机数据库, 系统正式上线可以移除此数据库
            services.AddScoped<SysPaySyncTask>();
            services.AddDbContext<AutoContext>(options => options.UseMySql("server=172.16.99.15;port=3306;user=Auto;password=MSTfA2PTAtDKJ4cG;database=auto", Microsoft.EntityFrameworkCore.ServerVersion.Parse("5.7.33-mysql")));
        }
    }
}